﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using TelecoSystems.ViewModels.Profile;

namespace TelecoSystems.Views.Profile {
    public partial class UserProfileView : ChildWindow {
        public UserProfileView(UserProfileViewModel viewModel) {
            InitializeComponent();

            DataContext = viewModel;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e) {
            this.DialogResult = false;
        }

        private void DataForm_EditEnded(object sender, DataFormEditEndedEventArgs e) {
            if (e.EditAction == DataFormEditAction.Commit) {
                var cmd = ((UserProfileViewModel)DataContext).SaveUserCommand;
                if (cmd.CanExecute(null)) {
                    cmd.Execute(null);
                }
            }
        }
    }
}

